package com.kb.erp.controller;

import com.kb.erp.common.ApiResponse;
import com.kb.erp.domain.resultData;
import com.kb.erp.service.IGenTableColumnService;
import com.kb.erp.service.SynData;
import com.kb.erp.util.GuavaCacheUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;



/**
 * 代码生成 操作处理
 * 
 * @author ruoyi
 */
@RestController
@RequestMapping("/synData")
public class SynDataController {

    @Autowired
    private SynData synData;
    @Resource
    private IGenTableColumnService iGenTableColumnService;
    /**
     *全量同步
     */
    @PostMapping("/synProcessCenter")
    @ResponseBody
    public void synProcessCenter(){
        synData.synProcessCenter();
    }

    /**
     *每日同步
     */
    @PostMapping("/everyDaySynProcessCenter")
    @ResponseBody
    public void everyDaySynProcessCenter(){
        synData.everyDaySynProcessCenter();
    }

    /**
     * 设置缓存
     * @return
     */
    @ResponseBody
    @GetMapping("/test1")
    public String test2 (){
        GuavaCacheUtil.setStr("aa","bb");
        return "ss";
    }

    /**
     * 获取缓存
     * @return
     */
    @ResponseBody
    @GetMapping("/test3")
    public String test3 (){
        String aa = GuavaCacheUtil.getStr("aa");
        return aa;
    }
    @ResponseBody
    @GetMapping("/test")
    public ApiResponse test(){
       return ApiResponse.success(iGenTableColumnService.deleteGenTableColumnByIds("2"));
    }

    @PostMapping("/data")
    public ApiResponse getData(
            @RequestParam(defaultValue = "1") int pageNo,
            @RequestParam(defaultValue = "10") int pageSize,
            String condition) {
//        IPage<GenTableColumn> pageData = iGenTableColumnService.getPageData(pageNo, pageSize, condition);
//        return ApiResponse.success(pageData);
        resultData resultData = new resultData();
        resultData.setUrl("http://127.0.0.1:8012/onlinePreview?url=aHR0cDovLzEyNy4wLjAuMTo4MDEyL2RlbW8vOC005bel5L2c5ZGo5oC757uTLnhsc3g%3D");
        return ApiResponse.success(resultData);
    }

    @PostMapping("/searchData")
    public ApiResponse searchData(@RequestBody Map map) {
        System.out.println(map);
        return ApiResponse.success(map);
    }
    public static void main(String[] args) {
        String regex = "^[^./T~#$@%^&*+<>:\"{},V/:J/im]+$";
//        var regEn = /[`~!#$%^&*+<>?:"{},\/;'[\]]/im,
//        regCn = /[·！#￥：；“”‘、，|《。》？、【】[\]]/im;
        String st = "imA_()434";
        // 创建Pattern对象
        Pattern pattern = Pattern.compile(regex);

        // 创建Matcher对象，并进行匹配
        Matcher matcher = pattern.matcher(st);
        if (matcher.find()) {
            System.out.println("匹配成功！");
        }
    }
}